import { createApp } from 'vue';
import { createPinia } from 'pinia';
import App from './App.vue';
import '../core/theme/tokens.css';
import '../core/theme/dark.css';
import '../core/theme/light.css';
import { useSettings } from '../core/store/useSettings';
import { useEngines } from '../core/store/useEngines';
import { useBookmarks } from '../core/store/useBookmarks';
import { toast as _toast, confirm as _confirm } from '../core/utils/feedback';

const app = createApp(App);
app.use(createPinia());

// 启动期统一初始化仓库，并应用主题
const settings = useSettings();
const engines = useEngines();
const bookmarks = useBookmarks();
settings.init().then(() => {
  // 应用主题
  document.documentElement.setAttribute('data-theme', settings.settings.theme);
});
engines.init();
bookmarks.init();

// 全局注入：兼容旧调用点
(window as any).gceToast = _toast;
(window as any).gceConfirm = _confirm;

app.mount('#app');
